//
//  Mjtest.m
//
//  Created by maxbalance on 12/2/15.
//
//

#import "Mjtest.h"
#import <Cordova/CDV.h>

@implementation Mjtest

#pragma mark test
- (void)test:(CDVInvokedUrlCommand*)command {
    NSDictionary* options = [command.arguments objectAtIndex:0];
    //test
    NSString *name  = [options objectForKey:@"name"];
    NSLog(@"%@",name);
}
- (void)plus:(CDVInvokedUrlCommand*)command {
    
//    [self.commandDelegate runInBackground:^{
//        
//        
// 
//    
//        
//    }];
//    
    NSInteger a = [[command.arguments objectAtIndex:0] integerValue];
    NSInteger b = [[command.arguments objectAtIndex:1] integerValue];
    NSInteger ret = a + b;
    
    CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsNSInteger:ret];
    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
    
    
    
 }

- (void)minus:(CDVInvokedUrlCommand*)command {
    NSInteger a = [[command.arguments objectAtIndex:0] integerValue];
    NSInteger b = [[command.arguments objectAtIndex:1] integerValue];
    NSInteger ret = a - b;
    
    CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsNSInteger:ret];
    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}

- (void)pushToPage:(CDVInvokedUrlCommand*)command {
    CDVPluginResult* pluginResult = nil;
    NSString* myarg = [command.arguments objectAtIndex:0];
    if (myarg != nil) {
        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
    } else {
        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Arg was null"];
    }
    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
    
    UIViewController *vc = [[UIViewController alloc]init];
    vc.view.backgroundColor = [UIColor greenColor];
   // [self.viewController.navigationController pushViewController:vc animated:YES];
    
    [self.viewController presentViewController:vc animated:YES completion:nil];
    
    
    
}





@end
